#include "content.h"
#include "input.h"

#include "drawingWidget.h"

#include "listButton.h"
#include "sliderButton.h"
#include "rotateButton.h"
#include "moveButton.h"
#include "saveButton.h"

#include "console.h"

#include "particleSystem.h"
#include "mesh.h"
#include "physicsActor.h"
#include "ragDoll.h"
#include "flexGrid.h"
#include "interpolationHelper.h"

#include "createActorButton.h"

#include "node.h"
#include "rootNode.h"
#include "waitForTimerNode.h"
#include "textInputButton.h"
#include "createNodeButton.h"

#include "propertyInspector.h"
#include "textureInspector.h"
#include "meshInspector.h"
#include "actionInspector.h"
#include "timelineInspector.h"
#include "prefabInspector.h"

#include "udpInput.h"
#include "pilot.h"
#include "mousePilot.h"
#include "action.h"


#include "spriteCharacter.h"

void Content::setup(){

    renderer=Renderer::getInstance();
    input=Input::getInstance();


    //*************************************************
    // 3D
    //*************************************************

    if (renderer->bRenderStereo){
        Button* monitor;
        monitor=new Button;
        monitor->location.x=0.0f;
        monitor->location.y=renderer->screenY;
        monitor->scale.x=renderer->screenX;
        monitor->scale.y=-renderer->screenY;
        monitor->textureID="rightEyeTexture";
        monitor->name="rightEye";
        //monitor->sceneShaderID="3DRightEye";
        monitor->sceneShaderID="texture";
        monitor->bScreenOverlay=true;
        renderer->leftEyeFBO=monitor;

        monitor=new Button;
        monitor->location.x=0.0f;
        monitor->location.y=renderer->screenY;
        monitor->scale.x=renderer->screenX;
        monitor->scale.y=-renderer->screenY;
        //monitor->textureID="leftEyeTexture";
        monitor->textureID="leftEyeTexture";
        monitor->name="leftEye";
        //monitor->sceneShaderID="3DLeftEye";
        monitor->sceneShaderID="texture";
        monitor->bScreenOverlay=true;
        //monitor->sceneShaderID="texture";
        renderer->rightEyeFBO=monitor;
        }

    //*************************************************
    // Shader Test
    //*************************************************


    Button *monitor;
    monitor=new Button;
    monitor->location.x=10.0f;
    monitor->location.y=300.0f;
    monitor->scale.x=160.0;
    monitor->scale.y=-120.0;
    monitor->textureID="depthTexture";
    monitor->name="depth Pass";
    //renderer->buttonList.push_back(monitor);
    monitor->bScreenOverlay=true;
    monitor->sceneShaderID="textureHDR";

    //To watch the different Ambient Occlusion Passes...

    monitor=new Button;
    monitor->location.x=180.0f;
    monitor->location.y=300.0f;
    monitor->scale.x=160.0;
    monitor->scale.y=-120.0;
    monitor->textureID="sceneTexture";
    monitor->name="color Pass";
    //renderer->buttonList.push_back(monitor);
    monitor->bScreenOverlay=true;

    monitor=new Button;
    /*
    monitor->location.x=360.0f;
    monitor->location.y=700.0f;
    monitor->scale.x=800.0;
    monitor->scale.y=-600.0;
    */

    monitor->location.x=0.0f;
    monitor->location.y=renderer->screenY;
    monitor->scale.x=renderer->screenX;
    monitor->scale.y=-renderer->screenY;

    monitor->textureID="sceneTexture";
    monitor->name="sfx";
    monitor->sceneShaderID="post";
    monitor->bDepthTextured=true;
    //renderer->buttonList.push_back(monitor);
    monitor->bScreenOverlay=true;


    //*************************************************
    // Buttons
    //*************************************************

    Button *but;
    ListButton *lbut;

    //console
    but= new Console;
    but->location.x=0;
    but->location.y=input->screenY-but->scale.y;
    but->bTextured=false;
    but->sceneShaderID="color";
    but->setup();
    renderer->buttonList.push_back(but);


    //Navigation Button

    but= new NavButton;
    but->location.x=10.0f;
    but->location.y=10;
    but->textureID="icon_fly";
    but->setup();
    but->parent=input->controller;
    input->controller->navBtn=(NavButton*) but;
    renderer->buttonList.push_back(but);

    //PropList
    lbut= new ListButton;
    lbut->location.x=10.0f;
    lbut->location.y=40;
    lbut->textureID="icon_props";
    lbut->name="propsMenu";

    //populate propList
    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place mesh");
    lbut->listProp.push_back("5Actor");
    lbut->listIcon.push_back("icon_base");

    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place camera");
    lbut->listProp.push_back("11CameraActor");
    lbut->listIcon.push_back("icon_camera");

    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place ragdoll");
    lbut->listProp.push_back("7RagDoll");
    lbut->listIcon.push_back("icon_base");

    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place Swansee");
    lbut->listProp.push_back("7Swansee");
    lbut->listIcon.push_back("icon_base");

    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place particle sys");
    lbut->listProp.push_back("16ParticleSystemCS");
    lbut->listIcon.push_back("icon_base");

    //--- test video actor
    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place video texture");
    lbut->listProp.push_back("17VideoTextureActor");
    lbut->listIcon.push_back("icon_base");

    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place bone");
    lbut->listProp.push_back("9BoneActor");
    lbut->listIcon.push_back("icon_base");

    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place SpriteCharacter");
    lbut->listProp.push_back("15SpriteCharacter");
    lbut->listIcon.push_back("icon_flat");

    lbut->listType.push_back("17CreateActorButton");
    lbut->listName.push_back("place UDPInput");
    lbut->listProp.push_back("8UdpInput");
    lbut->listIcon.push_back("icon_base");
    lbut->setup();
    renderer->buttonList.push_back(lbut);

    //DRAWING
    but= new DrawingWidget;
    but->location.x=10.0f;
    but->location.y=70;
    but->textureID="icon_brush";
    but->color=Vector4f(1.0,0.1,0.1,1.0);
    but->setup();
    renderer->buttonList.push_back(but);


    //NODELIST
    lbut= new ListButton;
    lbut->location.x=10.0f;
    lbut->location.y=100;
    lbut->textureID="icon_nodeMenu";
    lbut->name="nodeMenu";

    //populate nodeList
    lbut->listType.push_back("16CreateNodeButton");
    lbut->listType.push_back("16CreateNodeButton");
    lbut->listType.push_back("16CreateNodeButton");
    lbut->listType.push_back("16CreateNodeButton");
    lbut->listType.push_back("16CreateNodeButton");
    lbut->listType.push_back("16CreateNodeButton");
    lbut->listType.push_back("16CreateNodeButton");

    lbut->listName.push_back("RootNode");
    lbut->listName.push_back("WaitTime");
    lbut->listName.push_back("Interpolate");
    lbut->listName.push_back("KeyInput");
    lbut->listName.push_back("SwitchCamera");
    lbut->listName.push_back("PerformAction");
    lbut->listName.push_back("SetProperty");

    lbut->listProp.push_back("8RootNode");
    lbut->listProp.push_back("16WaitForTimerNode");
    lbut->listProp.push_back("15InterpolateNode");
    lbut->listProp.push_back("12KeyInputNode");
    lbut->listProp.push_back("16SwitchCameraNode");
    lbut->listProp.push_back("17PerformActionNode");
    lbut->listProp.push_back("15SetPropertyNode");


    lbut->listIcon.push_back("icon_base");
    lbut->listIcon.push_back("icon_base");
    lbut->listIcon.push_back("icon_base");
    lbut->listIcon.push_back("icon_base");
    lbut->listIcon.push_back("icon_base");
    lbut->listIcon.push_back("icon_base");
    lbut->listIcon.push_back("icon_base");

    renderer->buttonList.push_back(lbut);

    //SYSTEM
    lbut= new ListButton;
    lbut->location.x=10.0f;
    lbut->location.y=140;
    lbut->textureID="icon_system";
    lbut->name="sysMenu";

    lbut->listType.push_back("10SaveButton");
    lbut->listName.push_back("save");
    lbut->listProp.push_back("NULL");
    lbut->listIcon.push_back("icon_save");

    lbut->listType.push_back("10LoadButton");
    lbut->listName.push_back("load");
    lbut->listProp.push_back("NULL");
    lbut->listIcon.push_back("icon_load");
    lbut->setup();
    renderer->buttonList.push_back(lbut);


    /**************************************

    INSPECTORS

    **************************************/

    lbut= new PropertyInspector;
    lbut->location.x=renderer->screenX-30;
    lbut->location.y=0;
    lbut->name="propertyInspector";

    lbut->setup();
    renderer->buttonList.push_back(lbut);

    lbut= new TextureInspector;
    lbut->location.x=renderer->screenX-30;
    lbut->location.y=30;
    lbut->name="textureInspector";

    lbut->setup();
    renderer->buttonList.push_back(lbut);

    lbut= new MeshInspector;
    lbut->location.x=renderer->screenX-30;
    lbut->location.y=60;
    lbut->name="meshInspector";

    lbut->setup();
    renderer->buttonList.push_back(lbut);


    lbut= new ActionInspector;
    lbut->location.x=renderer->screenX-30;
    lbut->location.y=90;
    lbut->name="actionInspector";

    lbut->setup();
    renderer->buttonList.push_back(lbut);

    lbut= new PrefabInspector;
    lbut->location.x=renderer->screenX-30;
    lbut->location.y=120;
    lbut->name="prefabInspector";

    lbut->setup();
    renderer->buttonList.push_back(lbut);


    lbut= new TimelineInspector;
    lbut->location.x=200;
    lbut->location.y=renderer->screenY -lbut->scale.y;
    lbut->name="TimelineInspector";

    lbut->setup();
    renderer->buttonList.push_back(lbut);


 }


void Content::reset(){

renderer->actorList.clear();
renderer->buttonList.clear();
setup();
}

//{ Test Stuff
    //*************************************************
    // ambient occlusion example
    //*************************************************

    /*
    a=new Actor;
    a->location=Vector3f(0,1,0);
    a->scale=Vector3f(0.1,0.1,0.1);
    a->color=Vector4f(0.6,0.3,0.3,1.0);
    a->rotation=Vector3f(0,0,0);
    a->drawType=DRAW_MESH;
    a->name="donut";
    a->bUseShader=true;
    a->bTextured=false;
    a->bShadowTextured=true;
    a->textureID="noise";
    a->texFactorX=2;
    a->texFactorY=2;
    a->sceneShaderID="color";
    a->mesh="torus";
    renderer->actorList.push_back(a);

    a=new Actor;
    a->location=Vector3f(0.3,2.5,0);
    a->scale=Vector3f(0.05,0.05,0.1);
    a->color=Vector4f(0.6,0.6,0.3,1.0);
    a->rotation=Vector3f(0,0,0);
    a->drawType=DRAW_VBOMESH;
    a->name="donut2";
    a->bUseShader=true;
    a->bTextured=false;
    a->bShadowTextured=true;
    a->textureID="icon_base";
    a->texFactorX=1;
    a->texFactorY=1;
    a->sceneShaderID="color";
    a->mesh="torus";
    //a->vboMeshID="cube";
    a->vboMeshID="seymour";
    renderer->actorList.push_back(a);


    Button *monitor;
    monitor=new Button;
    monitor->location.x=10.0f;
    monitor->location.y=300.0f;
    monitor->scale.x=160.0;
    monitor->scale.y=-120.0;
    monitor->textureID="depthTexture";
    monitor->name="depth Pass";
    renderer->buttonList.push_back(monitor);

    //To watch the different Ambient Occlusion Passes...

    monitor=new Button;
    monitor->location.x=180.0f;
    monitor->location.y=300.0f;
    monitor->scale.x=160.0;
    monitor->scale.y=-120.0;
    monitor->textureID="sceneTexture";
    monitor->name="color Pass";
    renderer->buttonList.push_back(monitor);

    monitor=new Button;
    monitor->location.x=360.0f;
    monitor->location.y=400.0f;
    monitor->scale.x=400.0;
    monitor->scale.y=-300.0;
    monitor->textureID="sceneTexture";
    monitor->name="ssao";
    monitor->sceneShaderID="ambientOcclusion";
    monitor->bDepthTextured=true;
    renderer->buttonList.push_back(monitor);

    */
    //*************************************************
    // Nodes
    //*************************************************
//    but=new RootNode;
//    but->location=Vector3f(100,100,0);
//    renderer->buttonList.push_back(but);
//    Control::nodeList.push_back((Node*)but);
//
//    but=new WaitForTimerNode;
//    but->location=Vector3f(100,200,0);
//    renderer->buttonList.push_back(but);
//    Control::nodeList.push_back((Node*)but);
//
//    but=new Node;
//    but->location=Vector3f(400,100,0);
//    renderer->buttonList.push_back(but);
//    Control::nodeList.push_back((Node*)but);




    //************************
    //Flex Grid
    //************************

    //a=new FlexGrid;
    //a->name="flexGrid";
    //a->color=Vector4f(1.0,0.5,0.0,1.0);
    //renderer->actorList.push_back(a);

    //************************
    //Particle System
    //************************

    //ParticleSystem *p;
    //p=new ParticleSystem;
    //p->name="particleSystem";
    //p->sceneShaderID="particle";
    //p->texture=renderer->textureList[1];
    //p->addRandomParticles(5,1);
    //renderer->actorList.push_back(p);

//}
